from rest_framework.generics import ListAPIView, CreateAPIView
from product.models import Product
from Apis.serializers import ProductModelSerializer
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
class   ProductGListMixin(ListAPIView, CreateAPIView):

    queryset = Product.objects.all()
    serializer_class = ProductModelSerializer
    # 配置过滤器后端
    filter_backends = [DjangoFilterBackend,OrderingFilter]
    # 配置过滤的字段
    filterset_fields = ['product_name', 'price']
    # 配置排序的字段
    ordering_fields = ['id', 'price']
    # 默认字段设置
    ordering = ['id']
    